var Goody = new Class({
	Extends: DynaObject,
	initialize: function(subtype){
		this.parent(GAMEUNITTYPE.GOODY);
		game.goodies.push(this);
            if(subtype==null){
                if(game.exit==null){
                    this.subtype=GOODYSUBTYPE.EXIT;
                    game.exit=this;
                } else {
                    var goodyProbability=Math.round(Math.random()*30);
                    if(goodyProbability < 21)
                            this.subtype=GOODYSUBTYPE.BOMB; // +life , speed , passoverfakewalls , explosionLength/power
                    if(goodyProbability >= 21 && goodyProbability < 23)
                            this.subtype=GOODYSUBTYPE.LIFE;
                    if(goodyProbability >= 23 && goodyProbability < 25)
                            this.subtype=GOODYSUBTYPE.SPEED;
                    if(goodyProbability >= 25 && goodyProbability < 27)
                            this.subtype=GOODYSUBTYPE.EXPLOSIONLENGTH;
                    if(goodyProbability >= 27 && goodyProbability < 29)
                            this.subtype=GOODYSUBTYPE.PASSOVERFAKEWALLS;
                    if(goodyProbability >= 29)
                            this.subtype=GOODYSUBTYPE.SPEED; // could be another
                }
            } else {
                this.subtype=subtype;
            }
	},
        vaporate: function(){
            util.removeElementFromArray(this,game.goodies);
        },
        terminate: function(){
            this.vaporate();
            this.parent();
            if(this.subtype==GOODYSUBTYPE.EXIT)
                game.exit=null;
        }
});